package com.niit.mall.user.service.impl;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.niit.mall.api.client.ProductClient;
import com.niit.mall.common.api.CommonResult;
import com.niit.mall.user.domain.po.UserInfo;
import com.niit.mall.user.domain.vo.UserInfoVO;
import com.niit.mall.user.mapper.UserInfoMapper;
import com.niit.mall.user.service.IUserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @BelongsProject: pardo_mall_backend
 * @BelongsPackage: com.niit.mall.user.service.impl
 * @Author: ChuXuan
 * @CreateTime: 2025-06-04  20:42
 * @Description: 用户服务接口层实现
 * @Version: 1.0
 */
@Service
@RequiredArgsConstructor
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService {
	
	private final UserInfoMapper userInfoMapper;

	private final ProductClient productClient;

	
	@Override
	public UserInfoVO queryUserInfoByUserId(Long id) {

		UserInfo userInfo = userInfoMapper.queryUserInfoByUserId(id);
		// 查询用户优惠券数量
		Long couponNum = productClient.getCouponNum(id);
		userInfo.setCouponQuantity(couponNum);

		UserInfoVO userInfoVO = BeanUtil.copyProperties(userInfo, UserInfoVO.class);
		return userInfoVO;
	}
}
